<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Site_model extends CI_Model {

	public function _news_comment($user,$comment,$post_id){
		$date = date("Y-m-d G:i:s");
		$insert = array(
			'id' => '',
			'user_id' => $user,
			'news_feed_id' => $post_id,
			'comment' => $comment,
			'updated_at' => 'CURRENT_TIMESTAMP',
			'created_at' => $date
		);
		if($this->db->insert('news_comments',$insert)){
			return true;
		}else{
			return false;
		}
	}
	
	public function _validate_login($username,$password){
		if($username = NULL || $password = NULL)
			return false;
			
		if($user = $this->db->get_where('users',array('username' => $username))){
			foreach($user->result() as $row)
				$db_password = $row['password'];	
			
			if(md5($password) === $db_password)
				return true;
				
			else
				return false;
		}
		else
			return false;
	}

/* End of file site_model.php */
/* Location: ./application/models/site_model.php */